﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BFlatCompile
{
	internal class UniqueStringByIdTable
	{
		private int nextId = 1;
		private Dictionary<string, int> lookup = new Dictionary<string, int>();
		private List<string> strings = new List<string>() { "?????" };

		public int GetId(string value)
		{
			if (!this.lookup.ContainsKey(value))
			{
				this.lookup[value] = nextId++;
				this.strings.Add(value);
			}
			return this.lookup[value];
		}

		public string[] GetTable()
		{
			return this.strings.ToArray();
		}
	}
}
